package pub.cleangao.mybatis.expression;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
public class Tables {

    public static Tables lambda() {
        return new Tables();
    }

    private final List<JoinExpression> joinExpressionList = new ArrayList<>();


    public Tables innerJoin(String table, String eqColumn, List<String> columns, String prevTable, String prevEqColumn) {
        joinExpressionList.add(JoinExpression.buildExpression(FromJoint.INNER, table, eqColumn, columns, prevTable, prevEqColumn, joinExpressionList.size()));
        return this;
    }

    public Tables leftJoin(String table, String eqColumn, List<String> columns, String prevTable, String prevEqColumn) {
        joinExpressionList.add(JoinExpression.buildExpression(FromJoint.LEFT, table, eqColumn, columns, prevTable, prevEqColumn, joinExpressionList.size()));
        return this;
    }

    public Tables rightJoin(String table, String eqColumn, List<String> columns, String prevTable, String prevEqColumn) {
        joinExpressionList.add(JoinExpression.buildExpression(FromJoint.RIGHT, table, eqColumn, columns, prevTable, prevEqColumn, joinExpressionList.size()));
        return this;
    }

}
